home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.20000114-20000217 / 000140_news@columbia.edu _Tue Jan 25 12:57:45 2000.msg < prev    next >
Internet Message Format  |  2020-01-01  |  3KB

  1. Return-Path: <news@columbia.edu>
  2. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.59.30])
  3.     by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id MAA06669
  4.     for <kermit.misc@watsun.cc.columbia.edu>; Tue, 25 Jan 2000 12:57:45 -0500 (EST)
  5. Received: (from news@localhost)
  6.     by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id MAA15118
  7.     for kermit.misc@watsun.cc.columbia.edu; Tue, 25 Jan 2000 12:55:56 -0500 (EST)
  8. X-Authentication-Warning: newsmaster.cc.columbia.edu: news set sender to <news> using -f
  9. From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  10. Subject: Re: Changing Unix C-kermit> prompt
  11. Date: 25 Jan 2000 17:55:53 GMT
  12. Organization: Columbia University
  13. Message-ID: <86ko39$enr$1@newsmaster.cc.columbia.edu>
  14. To: kermit.misc@columbia.edu
  15.  
  16. In article <388DD7E6.ED7EA6A6@seanet.com>,
  17. Peter Burkholder  <peter@geophys.washington.edu> wrote:
  18. : I'm doing some script writing rather deep in my directory
  19. : tree, so I'm always looking at a prompt like:
  20. :   (/export/home/badger/spyder/kermit/ck7/) C-Kermit>
  21. : which hardly leaves space for my commands w/o wrapping.  I don't
  22. : see in the book or documentation how I truncate the current
  23. : directory listing, but I hope there is.  I'd be happy with;
  24. :   (ck7) C-Kermit>
  25. The prompt definition can contain macros, variables, function calls,
  26. or anything else.  The definition is re-evaluated each time the prompt
  27. changes.  The default definition is:
  28.  
  29.   (\v(directory)) C-Kermit>
  30.  
  31. which shows the current directory in parentheses; if you give a CD
  32. command, the prompt changes.
  33.  
  34. C-Kermit 7.0 includes a lot of new string functions.  Unfortunately, none
  35. of them does exactly what you need (one of them, \fstripx(), does exactly
  36. the opposite: removes the rightmost segment from the string).
  37.  
  38. But where there's a will, there's a way:
  39.  
  40.  set prompt (\freplace(\fsubstr(\v(dir),\frindex(/,\v(dir),2)),/,)) C-Kermit>
  41.  
  42. In which:
  43.  
  44. \frindex(/,\v(dir),2)
  45.   Gives the position of the rightmost slash not counting the trailing one.
  46.  
  47. \fsubstr(\v(dir),\frindex(/,\v(dir),2))
  48.   Gives the rightmost directory segment, with slashes
  49.  
  50. \freplace(\fsubstr(\v(dir),\frindex(/,\v(dir),2)),/,)
  51.   Removes the the slashes.
  52.  
  53. The result, in your case, should be:
  54.  
  55.   (ck7) C-Kermit>
  56.  
  57. You can achieve any other desired effect with C-Kermit's string functions.
  58. Most of them are documented in "Using C-Kermit".  New ones are documented
  59. in the ckermit2.txt file.  The SHOW FUNCTIONS command lists the functions
  60. that are available.  In C-Kermit 7.0, you can get help on a particular
  61. function with:
  62.  
  63.   help function xxx
  64.  
  65. where xxx is the function name.  This tells you the calling sequence,
  66. action, and return value.
  67.  
  68. - Frank